⬡ Hub
Skip to content

Amazon Rekognition: Video and Image Analysis

Amazon Rekognition makes it easy to add image and video analysis to your applications using proven, highly scalable, deep learning technology.


1. Key Features

🖼️ Image Analysis

  • Labels: Identify thousands of objects (trees, cars) and scenes (urban, beach).
  • Face Analysis: Detect faces and analyze attributes (eyes open, smile, gender).
  • Face Comparison: Compare a face in one image with faces in another to see if they match.
  • Text in Image: Detect and extract text from images (OCR).
  • Content Moderation: Detect inappropriate, explicit, or suggestive content.
  • PPE Detection: Identify if people are wearing Protective Personal Equipment (helmets, gloves, masks).

📹 Video Analysis (Stored & Streams)

  • Object Tracking: Track people or objects through a video file.
  • Activity Recognition: Detect actions like running, walking, or extinguished fire.
  • Streaming Video: Detect faces in live video streams using Kinesis Video Streams.

2. Technical Implementation

Face Detection (Python)

import boto3

def detect_faces(bucket, photo):
    client = boto3.client('rekognition')
    response = client.detect_faces(
        Image={'S3Object': {'Bucket': bucket, 'Name': photo}},
        Attributes=['ALL']
    )

    for face in response['FaceDetails']:
        print(f"Age Range: {face['AgeRange']['Low']} - {face['AgeRange']['High']}")
        print(f"Emotions: {face['Emotions'][0]['Type']}")

detect_faces("my-bucket", "user_photo.jpg")

Content Moderation (CLI)

aws rekognition detect-moderation-labels \
    --image '{"S3Object":{"Bucket":"my-bucket","Name":"upload.jpg"}}' \
    --min-confidence 75

3. Important Concepts

🏷️ Custom Labels

Use Custom Labels to identify objects unique to your business that a general model cannot recognize (e.g., custom machine parts, specific corporate logos, or agricultural pests). You provide just 10-20 images per label to train.

👥 Face Search (Collections)

To "recognize" a person, you must first create a Collection and index faces into it. 1. CreateCollection: A container to store face metadata (not the actual images). 2. IndexFaces: Extracts face features from an image and stores them in the collection. 3. SearchFacesByImage: Takes a new image and looks for matches within the collection.


4. FAQs for Interviews

  1. Does Rekognition store my images?
    • No, it processes images and returns metadata. If using collections, it stores high-dimensional "face vectors," not the actual pixels.
  2. How do you handle privacy concerns?
    • Use IAM policies to restrict access, enable encryption (KMS) for S3 buckets holding images, and utilize Content Moderation to filter inappropriate user uploads.
  3. What is the difference between Rekognition and Textract?
    • Rekognition: Best for simple OCR in real-world scenes (signs, posters).
    • Textract: Specifically designed for document analysis (forms, tables, complex layouts).